<?php
//april 10, 2008


class blog extends Model {

	public $table = 'blogs';
	
	public function getTags()
	{
		$query = new Query("SELECT * FROM `blog_tag_relations` WHERE `blog` = ? ORDER BY `id` DESC", $this->id);
				
		if($query->num_rows() > 0)
		{
			$blog_tags = blog_blogTag::RecordSet($query, 'blog_blogTag');
			
			for($i = 0; $i < count($blog_tags); $i++)
			{
				$this->transformed['tag'][$i] = new tag($blog_tags[$i]->tag);
			}
			
			return true;
		}
		else
		{
			return false;
		}
	}
	
	public function getComments()
	{
		$query = new Query("SELECT * FROM `comments` WHERE `blog` = ? ORDER BY `date` DESC", $this->id);
		if($query->num_rows() > 0)
		{
			$comments = comment::recordSet($query, 'comment');
			
			#display comments
			for($i = 0; $i < count($comments); $i++)
			{
				$this->transformed['comment'][$i] = new comment($comments[$i]->id);
			}
			
			return true;
		}
		else
		{
			return false;
		}
	}

}

?>